import serial

####################
port = '/dev/ttyUSB0'
stopbits = 1
parity = 'N'
timeout = None
baudrate = 9600
bytesize = serial.EIGHTBITS
parity = serial.PARITY_NONE
stopbits = serial.STOPBITS_ONE
####################

#configuring the port
ser = serial.Serial()
ser.port = port
ser.baudrate = baudrate

print ser
#Serial<id=0xb71d43ac, open=True>(port='/dev/ttyUSB0', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=0, rtscts=0, dsrdtr=0)

#open the port
ser.open()
#check if open
print ser.isOpen()

#send data to the port
ser.write('a')

#close the port
ser.close()
print ser.isOpen()

